"""
前瞻回溯记忆问卷（Prospective and Retrospective Memory Questionnaire, PRMQ）是一种用于评估个体前瞻性记忆和回顾性记忆的量表。
PRMQ包含16个条目，每个条目的得分范围是1到5分，总分范围是16到80分。根据总分，可以评估前瞻性记忆和回顾性记忆的损害程度。
"""
class PRMQ:
    def __init__(self, answers):
        self.answers = answers
        self.total_score = 0
        self.prospective_memory_score = 0
        self.retrospective_memory_score = 0

    def calculate_scores(self):
        self._calculate_prospective_memory()
        self._calculate_retrospective_memory()
        self._calculate_total_score()

    def _calculate_prospective_memory(self):
        prospective_memory_questions = [1, 2, 3, 4, 5, 6, 7, 8]
        self.prospective_memory_score = sum(int(self.answers[f'q{i}']) for i in prospective_memory_questions)

    def _calculate_retrospective_memory(self):
        retrospective_memory_questions = [9, 10, 11, 12, 13, 14, 15, 16]
        self.retrospective_memory_score = sum(int(self.answers[f'q{i}']) for i in retrospective_memory_questions)

    def _calculate_total_score(self):
        self.total_score = self.prospective_memory_score + self.retrospective_memory_score

    def get_scores(self):
        return {
            'total_score': self.total_score,
            'prospective_memory_score': self.prospective_memory_score,
            'retrospective_memory_score': self.retrospective_memory_score
        }

# # 示例使用
# answers = {
#     'q1': '3', 'q2': '2', 'q3': '1', 'q4': '5', 'q5': '2', 'q6': '1', 'q7': '3', 'q8': '2',
#     'q9': '1', 'q10': '5', 'q11': '3', 'q12': '2', 'q13': '1', 'q14': '5', 'q15': '2', 'q16': '1'
# }
#
# prmq = PRMQ(answers)
# prmq.calculate_scores()
# scores = prmq.get_scores()
# print("Total Score:", scores['total_score'])
# print("Prospective Memory Score:", scores['prospective_memory_score'])
# print("Retrospective Memory Score:", scores['retrospective_memory_score'])